package com.uplooking.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.uplooking.pojo.GoodVO;

public interface GoodDO extends JpaRepository<GoodVO, String>,
	JpaSpecificationExecutor<GoodVO> {

	@Query(nativeQuery=true,value="SELECT count(gno) FROM tblgood WHERE gstatus = 401 "
			+ "and if (:name is not null and :name != '' , gname like concat('%',:name,'%') , 1=1) "
			+ "and if (:type is not null and :type != '' , gtype = :type , 1=1)")
	long count(@Param("name") String name,@Param("type") String type);
	
	@Query(nativeQuery=true,value="SELECT gno FROM tblgood WHERE gstatus = 401 "
			+ "and if (:name is not null and :name != '' , gname like concat('%',:name,'%') , 1=1) "
			+ "and if (:type is not null and :type != '' , gtype = :type , 1=1) limit :start,:limit")
	List<String> find(@Param("name") String name,@Param("type") String type
			,@Param("start")int start,@Param("limit")int limit);
}
